<taglib name="Admin\TagLib\EasyUI" />

<easyui:datagrid options="datagrid.options" fields="datagrid.fields" />

<!-- 添加用户 -->
<div id="message_messagelist_add_dialog" class="easyui-dialog" title="发布新消息"
     data-options="modal:true,closed:true,iconCls:'icons-application-application_add',
     buttons:[{text:'确定',iconCls:'icons-other-tick',
     handler:function(){$('#message_messagelist_add_dialog_form').submit();}},
     {text:'取消',iconCls:'icons-arrow-cross',
     handler:function(){$('#message_messagelist_add_dialog').dialog('close');}}]"
     style="width:480px;height:260px;">

     </div>




<script type="text/javascript">
    var message_messagelist_datagrid_toolbar = [
        { text: '发布新消息', iconCls: 'icons-table-table_add', handler:    messageMessageAdd },
        { text: '刷新', iconCls: 'icons-table-table_refresh', handler:    messageMessageRefresh }
    ];

    //操作格式化
    function messageListOperateFormatter(val){
        var btn = [];
       /* btn.push('<a href="javascript:;" onclick="missionView('+val+')">查看</a>');*/
        /*btn.push('<a href="javascript:;" onclick="missionBlack('+val+')">拉黑/启用</a>');*/
        btn.push('<a href="javascript:;" onclick="messageDelete('+val+')">删除</a>');
        return btn.join(' | ');
    }

    //刷新
    function messageMessageRefresh(){
        $('#message_messagelist_datagrid').datagrid('reload');
    }

    function messageMessageAdd(){
        var url = '<{:U('Message/messageAdd')}>';
        $('#message_messagelist_add_dialog').dialog({href:url});
        $('#message_messagelist_add_dialog').dialog('open');

    }



    function messageDelete(id){
        if(typeof(id) !== 'number'){
            $.messager.alert('提示信息', '未选择用户', 'error');
            return false;
        }
        $.messager.confirm('提示信息', '确定要删除吗？', function(result){
            if(!result) return false;
            $.post('<{:U('Message/messageDelete')}>', {id: id}, function(res){
                if(!res.status){
                    $.messager.alert('提示信息', res.info, 'error');
                }else{
                    $.messager.alert('提示信息', res.info, 'info');
                    messageMessageRefresh();
                }
            }, 'json');
        });
    }



</script>